home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-187.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  48.0 KB  |  1,127 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Tue, 20 Oct 92       Volume 1 : Issue 187
  2.  
  3. Today's Topics:
  4.  
  5.     Patching the _Launch Trap
  6.     GetColor bug (was RE: NON-QUICKDRAW GAMES)
  7.     Palette Manager vs. Color Manager (was Re: NON-QUICKDRAW GAMES)
  8.     The Pallette manager
  9.  
  10.  
  11.  
  12. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  13.  
  14. The digest is a collection of article threads from the internet newsgroup
  15. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  16. regularly and want an archive of the discussions.  If you don't know what a
  17. newsgroup is, you probably don't have access to it.  Ask your systems
  18. administrator(s) for details.  (This means you can't post questions to the
  19. digest.)
  20.  
  21. Each issue of the digest contains one or more sets of articles (called
  22. threads), with each set corresponding to a 'discussion' of a particular
  23. subject.  The articles are not edited; all articles included in this digest
  24. are in their original posted form (as received by our news server at
  25. cs.uoregon.edu).  Article threads are not added to the digest until the last
  26. article added to the thread is at least one month old (this is to ensure that
  27. the thread is dead before adding it to the digest).  Article threads that
  28. consist of only one message are generally not included in the digest.
  29.  
  30. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  31. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  32. file /pub/mac/csmp-digest/README before downloading any files.  The most
  33. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  34. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  35. archive has a mail server; send a message with the text '$MACarch help' (no
  36. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  37.  
  38. The digest is also available via email.  Just send a note saying that you
  39. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  40. automatically receive each new issue as it is created.  Sorry, back issues
  41. are not available through the mailing list.
  42.  
  43. Send administrative mail to mkelly@cs.uoregon.edu.
  44.  
  45.  
  46. -------------------------------------------------------
  47.  
  48. From: John Champion <dedjhc@arco.com>
  49. Subject: Patching the _Launch Trap
  50. Organization: Arco Alaska Inc.
  51. Date: Tue, 8 Sep 1992 02:40:49 GMT
  52.  
  53. Hi all,
  54. I'm trying to install a fairly unobtrusive head patch into the _Launch
  55. trap.  The problem is that no matter what I do, my patch always gets
  56. re-patched (presumeably by the system).  This unknown code does not pass
  57. control down the line like a normal patch would, so my code never gets
  58. called.
  59.  
  60. I've tried patching at various times during startup to no avail.  If I
  61. patch at init-launching time, my code gets called once (when Finder is
  62. launched) and nevermore after that point.  If I patch after startup has
  63. completed, then my patch gets re-patched before my code gets called even
  64. once!
  65.  
  66. I'm using system 7, and I have no problem requiring it for my
  67. application.  Does anyone have any ideas for getting around this
  68. patch-happy little gremlin?  Thanks in advance for any advice.
  69.  
  70.  
  71. - -John Champion      dedjhc@arco.com
  72.  
  73. +++++++++++++++++++++++++++
  74.  
  75. From: leonardr@netcom.com (Leonard Rosenthol)
  76. Date: Tue, 08 Sep 92 06:56:48 GMT
  77. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  78.  
  79. In article <1992Sep8.024049.20121@Arco.COM> John Champion <dedjhc@arco.com> writes:
  80. >Hi all,
  81. >I'm trying to install a fairly unobtrusive head patch into the _Launch
  82. >trap.  The problem is that no matter what I do, my patch always gets
  83. >re-patched (presumeably by the system).  This unknown code does not pass
  84. >control down the line like a normal patch would, so my code never gets
  85. >called.
  86. >
  87.     Welcome to the wonderful world of "protected patches".  This is a
  88. new trick in System 7 to make sure that programmers don't "screw up" system
  89. patches.  It basically means that it is near impossible to patch such a trap.
  90.  
  91.     If you could post what you are trying to accomplish by patching _Launch
  92. someone could probably suggest an alternate approach that would be successful.
  93.  
  94. - -- 
  95. - -----------------------------------------------------------------------------
  96. Leonard Rosenthol            Internet:     leonardr@netcom.com
  97. Director of Advanced Technology        AppleLink:    MACgician
  98. Aladdin Systems, Inc.            GEnie:        MACgician
  99.  
  100.  
  101. +++++++++++++++++++++++++++
  102.  
  103. From: dedjhc@arco.com (John Champion)
  104. Date: 8 Sep 92 14:51:00 GMT
  105. Organization: Arco Alaska Inc.
  106.  
  107. In article <abrn6k+.leonardr@netcom.com> Leonard Rosenthol,
  108. leonardr@netcom.com writes:
  109. >    Welcome to the wonderful world of "protected patches".  This is a
  110. >new trick in System 7 to make sure that programmers don't "screw up"
  111. system
  112. >patches.  It basically means that it is near impossible to patch such a
  113. trap.
  114. >
  115. >    If you could post what you are trying to accomplish by patching _Launch
  116. >someone could probably suggest an alternate approach that would be
  117. successful.
  118.  
  119. I need FSSpec type information on applications and associated documents
  120. that are launched, particularly by the finder.  Unfortunately, not all
  121. applications accept apple events so I can't just check for those.
  122.  
  123. - -John Champion      dedjhc@arco.com
  124.  
  125. +++++++++++++++++++++++++++
  126.  
  127. From: leonardr@netcom.com (Leonard Rosenthol)
  128. Date: 8 Sep 92 17:09:43 GMT
  129. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  130.  
  131. In article <1992Sep8.145100.26889@Arco.COM> John Champion <dedjhc@arco.com> writes:
  132. >In article <abrn6k+.leonardr@netcom.com> Leonard Rosenthol,
  133. >leonardr@netcom.com writes:
  134. >>
  135. >>    If you could post what you are trying to accomplish by patching _Launch
  136. >>someone could probably suggest an alternate approach that would be
  137. >successful.
  138. >
  139. >I need FSSpec type information on applications and associated documents
  140. >that are launched, particularly by the finder.  Unfortunately, not all
  141. >applications accept apple events so I can't just check for those.
  142. >
  143.     Well, finding applications are easy, but getting documents may be a
  144. bit difficult since they are not "launched".  
  145.  
  146.     One way that might work, assuming that you only care about System 7
  147. would be to intercept 'osel' events in the Finder.  When the Finder "opens"
  148. anything, file, folder, disk, etc. it will send itself an 'osel' event - also
  149. many launching utils will also send the same event to the Finder in order to 
  150. have things opened.
  151.  
  152.     There are two ways to intercept Apple events.  The hard way is to patch
  153. _Pack8 (Apple Event manager), the easy (but undocumented way) is to install
  154. something called a PHAQHandler.  A PHAQHandler is the equivalent of a head
  155. patch on an Apple event handler, so you could just grab the data for the event
  156. and then pass it along.  You might also be able to do the same thing by 
  157. getting the address of the current 'osel' handler, installing your own and
  158. then calling the original...
  159.  
  160. - -- 
  161. - -----------------------------------------------------------------------------
  162. Leonard Rosenthol            Internet:     leonardr@netcom.com
  163. Director of Advanced Technology        AppleLink:    MACgician
  164. Aladdin Systems, Inc.            GEnie:        MACgician
  165.  
  166. +++++++++++++++++++++++++++
  167.  
  168. From: keith@taligent.com (Keith Rollin)
  169. Organization: Taligent
  170. Date: Tue, 8 Sep 1992 21:33:29 GMT
  171.  
  172. In article <abrn6k+.leonardr@netcom.com>, leonardr@netcom.com (Leonard
  173. Rosenthol) writes:
  174. > In article <1992Sep8.024049.20121@Arco.COM> John Champion <dedjhc@arco.com>
  175. writes:
  176. > >Hi all,
  177. > >I'm trying to install a fairly unobtrusive head patch into the _Launch
  178. > >trap.  The problem is that no matter what I do, my patch always gets
  179. > >re-patched (presumeably by the system).  This unknown code does not pass
  180. > >control down the line like a normal patch would, so my code never gets
  181. > >called.
  182. > >
  183. >     Welcome to the wonderful world of "protected patches".  This is a
  184. > new trick in System 7 to make sure that programmers don't "screw up" system
  185. > patches.  It basically means that it is near impossible to patch such a trap.
  186.  
  187. The problem with patching _Launch is not that it's protected. You can patch
  188. protected patches; you just won't be the first in the chain when you're done.
  189.  
  190. The problem with patching _Launch is that it is patched after INIT time, and
  191. doesn't call the original trap. You'd have the same problem with other traps as
  192. well, notably Window Manager traps.
  193.  
  194.  
  195. In article <1992Sep8.145100.26889@Arco.COM> John Champion <dedjhc@arco.com>
  196. writes:
  197. >In article <abrn6k+.leonardr@netcom.com> Leonard Rosenthol,
  198. >leonardr@netcom.com writes:
  199. >>
  200. >>    If you could post what you are trying to accomplish by patching _Launch
  201. >>someone could probably suggest an alternate approach that would be
  202. >successful.
  203. >
  204. >I need FSSpec type information on applications and associated documents
  205. >that are launched, particularly by the finder.  Unfortunately, not all
  206. >applications accept apple events so I can't just check for those.
  207. >
  208.  
  209. I do something like this. I patch InitGraf right now, but I'm considering a
  210. scheme where I patch InitAllPacks, instead. The problem with patching InitGraf
  211. is in determining if the call is being made from the start of an application.
  212. Some InitGraf calls are made from INITs at INIT time (by ShowINIT, for example);
  213. some applications call InitGraf more than once (applications written with THINK
  214. Pascal are common "offenders"); and CE Toolbox calls InitGraf at shutdown time
  215. under certain circumstances. If you patch InitGraf, you'll have to look out for
  216. all these cases.
  217.  
  218. - --
  219. Keith Rollin
  220. Phantom Programmer
  221. Taligent, Inc.
  222.  
  223.  
  224. +++++++++++++++++++++++++++
  225.  
  226. From: bwilliam@iat.holonet.net (Bill Williams)
  227. Organization: HoloNet (BBS: 510-704-1058)
  228. Date: Wed, 9 Sep 1992 05:04:39 GMT
  229.  
  230. >It basically means that it is near impossible to patch such a
  231. trap....
  232.  
  233. I am not positive but two years ago at MacHack during the forum discussing
  234. "the correct way to write any kind of INIT" that was headed by several
  235. Apple employees, I could have sweared that I thought I heard a panelist
  236. mention that there was a reserved way to patch than involved setting a
  237. value in memory. I vaguely feel that it was setting a LoMem to a special
  238. value befor calling SetTrapAddress or something higher up on the stack.
  239.  
  240. Anyway I'll bet Apple has some official ways to patch just about anything
  241. in system seven internally. Or at least I'd wish they did.
  242.  
  243. BWilliams
  244.  
  245.  
  246. +++++++++++++++++++++++++++
  247.  
  248. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  249. Date: 10 Sep 92 06:49:36 GMT
  250. Organization: University of Waikato, Hamilton, New Zealand
  251.  
  252. In article <gvrn-n#.leonardr@netcom.com>, leonardr@netcom.com (Leonard Rosenthol) writes:
  253.  
  254. >     One way that might work, assuming that you only care about System 7
  255. > would be to intercept 'osel' events in the Finder.  When the Finder "opens"
  256. > anything, file, folder, disk, etc. it will send itself an 'osel' event - also
  257. > many launching utils will also send the same event to the Finder in order to
  258. > have things opened.
  259. >
  260. >     There are two ways to intercept Apple events.  The hard way is to patch
  261. > _Pack8 (Apple Event manager), the easy (but undocumented way) is to install
  262. > something called a PHAQHandler.  A PHAQHandler is the equivalent of a head
  263. > patch on an Apple event handler, so you could just grab the data for the event
  264. > and then pass it along.  You might also be able to do the same thing by
  265. > getting the address of the current 'osel' handler, installing your own and
  266. > then calling the original...
  267.  
  268. This may work with Finder 7.1 (not that I've seen it), but it certainly won't
  269. work with Finder 7.0. Finder 7.0 doesn't use the Apple Event Manager for doing
  270. its own event handling, so it's no good trying to intercept Finder events by
  271. doing anything to or with the Apple Event Manager. Not from within the Finder's
  272. process context, anyway. You'll have to patch AcceptHighLevelEvent.
  273.  
  274. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  275. Computer Services Dept                     fax: +64-7-838-4066
  276. University of Waikato            electric mail: ldo@waikato.ac.nz
  277. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  278. This line intentionally left unfunny.
  279.  
  280. +++++++++++++++++++++++++++
  281.  
  282. From: jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  283. Date: 9 Sep 92 17:21:36 GMT
  284. Organization: Computer Science Dept, QMW, University of London
  285.  
  286. In <BuA3vu.97H@taligent.com> keith@taligent.com (Keith Rollin) writes:
  287.  
  288. >I do something like this. I patch InitGraf right now, but I'm considering a
  289. >scheme where I patch InitAllPacks, instead. The problem with patching InitGraf
  290. >is in determining if the call is being made from the start of an application.
  291. >Some InitGraf calls are made from INITs at INIT time (by ShowINIT, for example);
  292. >some applications call InitGraf more than once (applications written with THINK
  293. >Pascal are common "offenders"); and CE Toolbox calls InitGraf at shutdown time
  294. >under certain circumstances. If you patch InitGraf, you'll have to look out for
  295. >all these cases.
  296.  
  297. The other problem with patching _InitGraf is that it doesn't
  298. move memory, so neither can (should) your patch. We won't get
  299. into the "all traps move memory because of patches" here! You
  300. can argue that unexpectedly moving memory within _InitGraf
  301. probably won't matter because of the way in which apps call it,
  302. but it's a little unsafe. _InitFonts, on the other hand, does
  303. move memory and is usually called immediately after _InitGraf.
  304.  
  305. When is _InitAllPacks called?
  306.  
  307. Jeremy
  308.  
  309. +++++++++++++++++++++++++++
  310.  
  311. From: keith@taligent.com (Keith Rollin)
  312. Date: 10 Sep 92 05:59:50 GMT
  313. Organization: Taligent
  314.  
  315. In article <1992Sep9.172136.13700@dcs.qmw.ac.uk>, jeremyr@dcs.qmw.ac.uk (Jeremy
  316. Roussak) writes:
  317. > In <BuA3vu.97H@taligent.com> keith@taligent.com (Keith Rollin) writes:
  318. > >I do something like this. I patch InitGraf right now, but I'm considering a
  319. > >scheme where I patch InitAllPacks, instead. The problem with patching
  320. InitGraf
  321. > >is in determining if the call is being made from the start of an application.
  322. > >Some InitGraf calls are made from INITs at INIT time (by ShowINIT, for
  323. example);
  324. > >some applications call InitGraf more than once (applications written with
  325. THINK
  326. > >Pascal are common "offenders"); and CE Toolbox calls InitGraf at shutdown
  327. time
  328. > >under certain circumstances. If you patch InitGraf, you'll have to look out
  329. for
  330. > >all these cases.
  331. > The other problem with patching _InitGraf is that it doesn't
  332. > move memory, so neither can (should) your patch. We won't get
  333. > into the "all traps move memory because of patches" here! You
  334. > can argue that unexpectedly moving memory within _InitGraf
  335. > probably won't matter because of the way in which apps call it,
  336. > but it's a little unsafe. _InitFonts, on the other hand, does
  337. > move memory and is usually called immediately after _InitGraf.
  338.  
  339. You make a good point concerning patching _InitGraf. I had thought about it at
  340. the time, but went ahead and patched it, figuring that I was safe for the
  341. reasons you gave.
  342.  
  343. > When is _InitAllPacks called?
  344.  
  345. After your application is loaded, but just before its entry point is called.
  346.  
  347. - --
  348. Keith Rollin
  349. Phantom Programmer
  350. Taligent, Inc.
  351.  
  352. +++++++++++++++++++++++++++
  353.  
  354. From: jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  355. Date: 10 Sep 92 17:54:27 GMT
  356. Organization: Computer Science Dept, QMW, University of London
  357.  
  358. In <BuCLzq.A7z@taligent.com> keith@taligent.com (Keith Rollin) writes:
  359.  
  360. >In article <1992Sep9.172136.13700@dcs.qmw.ac.uk>, jeremyr@dcs.qmw.ac.uk (Jeremy
  361. >Roussak) writes:
  362. >>
  363. >> The other problem with patching _InitGraf is that it doesn't
  364. >> move memory, so neither can (should) your patch. We won't get
  365. >> into the "all traps move memory because of patches" here! You
  366. >> can argue that unexpectedly moving memory within _InitGraf
  367. >> probably won't matter because of the way in which apps call it,
  368. >> but it's a little unsafe. _InitFonts, on the other hand, does
  369. >> move memory and is usually called immediately after _InitGraf.
  370.  
  371. >You make a good point concerning patching _InitGraf. I had thought about it at
  372. >the time, but went ahead and patched it, figuring that I was safe for the
  373. >reasons you gave.
  374. >>
  375. >> When is _InitAllPacks called?
  376. >>
  377.  
  378. >After your application is loaded, but just before its entry point is called.
  379.  
  380. Are you sure this is correct? I just tried trapping with
  381. MacsBug on _InitAllPacks: the file dcmd fails to show that the
  382. application's resource file is open, CurMap is
  383. FinderPreferences and CurApRefNum is the Finder. (SE/30, 7.0
  384. tuned). If the app's resource file isn't available, it's tricky
  385. to find it's details. CurApName is correctly set up, though.
  386.  
  387. Jeremy
  388.  
  389. ---------------------------
  390.  
  391. From: John_Miller@mindlink.bc.ca (John Miller)
  392. Subject: GetColor bug (was RE: NON-QUICKDRAW GAMES)
  393. Date: 9 Sep 92 20:46:59 GMT
  394. Organization: MIND LINK! - British Columbia, Canada
  395.  
  396. In article <18lbbfINNsdp@agate.berkeley.edu>,
  397. Ben Haller (deadman@garnet.berkeley.edu) writes
  398. >  BTW, anybody noticed the charming System 7 bug that when the
  399. > Color Picker comes up, after you dismiss it it leaves the CLUT
  400. > fucked up?  Charming.  They haven't fixed that one yet, have they?
  401.  
  402. Yep.  Been meaning to post a message about that for months
  403. now.  Haven't tried Apple's latest color stuff, but as of
  404. Tuned-up System 7, the bug was still there.  Didn't
  405. occur under System 6 with or without 32-Bit QuickDraw.
  406.  
  407. Rather annoying behaviour for a call that is documented to put
  408. everything back the way it was.  Fortunately, writing an
  409. crude alternate color dialog for CLUT devices was quick
  410. enough, but it was an frustrating last minute discovery.
  411.  
  412. (I had a good excuse for not using the Palette Manager.
  413. I was colorizing HyperCard's stack window.  The Palette
  414. Manager doesn't think that attaching a palette to a
  415. B&W window is a very groovy idea.)
  416.  
  417. I guess Apple engineers only use 24-bit displays these days.
  418. Goes along with those 2 gigabyte disk drives and 64 Meg
  419. of RAM they use for running MPW/CFront/MacApp/OtherNeatTools.  :) :)
  420.  
  421. John Miller
  422. Symplex Systems
  423.  
  424. +++++++++++++++++++++++++++
  425.  
  426. From: brad@vedge.UUCP (Brad Fowlow)
  427. Date: 10 Sep 92 17:26:37 GMT
  428. Organization: Visual Edge Software, St. Laurent, Quebec
  429.  
  430. John_Miller@mindlink.bc.ca (John Miller) writes:
  431. : In article <18lbbfINNsdp@agate.berkeley.edu>,
  432. : Ben Haller (deadman@garnet.berkeley.edu) writes
  433. : >  BTW, anybody noticed the charming System 7 bug that when the
  434. : > Color Picker comes up, after you dismiss it it leaves the CLUT
  435. : > fucked up?  Charming.  They haven't fixed that one yet, have they?
  436. : ....
  437. : Rather annoying behaviour for a call that is documented to put
  438. : everything back the way it was.  Fortunately, writing an
  439. : crude alternate color dialog for CLUT devices was quick
  440. : enough, but it was an frustrating last minute discovery.
  441.  
  442. An observation:
  443.  
  444. It restores things, but in the palette manager's terms;
  445. after the dialog goes away, the palette manager is free to 
  446. satisfy the color requirements of the next FrontWindow.
  447.  
  448. One thing folks (or else I) seem to have missed
  449. is what is promised for a window without a palette.
  450. The color environment for a color window without a palette
  451. isn't the "normal" system palette, it's black and white,
  452. and a gray and the highlight color if possible;
  453. other colors get matched at the convenience of the PM.
  454.  
  455. So the dismiss behaviour of the color picker 
  456. is (sort of) a good thing; the palette manager
  457. is reducing the amount of window refresh by changing
  458. the color env only so far as it must to meet the stated
  459. requirements of the front window.
  460.  
  461.  
  462. A question:
  463.  
  464. I don't see how to change this behavior without going under the PM.
  465. That is, I can't see how to kick the palette manager into using
  466. a palette without using a window that the palette is attached to.
  467.  
  468. For example,
  469. I have (in an app) zero or more open windows each with its
  470. own palette.  Switching among these windows is a rock video,
  471. but they do get updated quite well. After closing the
  472. last window, its color env stays around, because there's no
  473. other window demanding its own colors.   Quitting the application
  474. seems to kick the PM into restoring the "normal" color env
  475. (perhaps the Finder is doing this?).   I'd like this
  476. to happen whenever a last window closes.
  477.  
  478. But I don't see how to get the PM to change the color environment
  479. without having a window active and setting its Palette.
  480. As long as the app is running, the pm won't retire that
  481. last window's colors until forced by another paletted window,
  482. and as we've noticed, there aren't many of those.
  483.  
  484. Any thoughts on a PM-friendly way to get back the "normal"
  485. system palette when my last paletted window dies,
  486. just as happens when the app quits?
  487.  
  488. - - brad
  489.  
  490. - -- 
  491. - -------------------------------------------------------------
  492.  Brad Fowlow   brad@vedge.com     Visual Edge Software Limited  
  493.  
  494. +++++++++++++++++++++++++++
  495.  
  496. From: Joe.Francis@dartmouth.edu (Joe Francis)
  497. Date: 11 Sep 92 00:59:24 GMT
  498. Organization: Dartmouth College, Hanover, NH
  499.  
  500. In article <28629@vedge.UUCP>
  501. brad@vedge.UUCP (Brad Fowlow) writes:
  502.  
  503. > Any thoughts on a PM-friendly way to get back the "normal"
  504. > system palette when my last paletted window dies,
  505. > just as happens when the app quits?
  506.  
  507. I'm hopeful that someone else will post a more elegant way, but one way
  508. to do what you want is to detect when you are closing your only window,
  509. EraseRect it's portRect, and set it's Palette to the system palette,
  510. *then* close the window.  
  511.  
  512. +++++++++++++++++++++++++++
  513.  
  514. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  515. Organization: Kalamazoo College
  516. Date: Fri, 11 Sep 1992 17:12:07 GMT
  517.  
  518. Joe.Francis@dartmouth.edu (Joe Francis) writes:
  519. >brad@vedge.UUCP (Brad Fowlow) writes:
  520. >
  521. >> Any thoughts on a PM-friendly way to get back the "normal"
  522. >> system palette when my last paletted window dies,
  523. >> just as happens when the app quits?
  524. >
  525. >I'm hopeful that someone else will post a more elegant way, but one way
  526. >to do what you want is to detect when you are closing your only window,
  527. >EraseRect it's portRect, and set it's Palette to the system palette,
  528. >*then* close the window.  
  529.  
  530. On the puzzle page in develop #11 (available from ftp.apple.com), Kon &
  531. Bal write: "In 32-Bit QuickDraw David Van Brink extended the Palette
  532. Manager to include a routine called PaletteMgrExit. This routine is
  533. called automatically for you when your application quits, thus restoring
  534. the default color state."
  535.  
  536. Macsbug doesn't know that word, but you might want to try snooping
  537. around (maybe step through ExitToShell, not that I'd like to try it).
  538. Maybe you could shut down and re-init the Palette Manager?
  539.  
  540. Somehow I doubt that using an undocumented trap qualifies as an
  541. "elegant" solution, but I thought I'd pass it along...
  542. - -- 
  543.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  544.  The essence of OOP:  "After some hacking, I finally got the program to
  545.  work, but I'm still not sure why." - David Marcovitz (marcovitz@uiuc.edu)
  546.  
  547. +++++++++++++++++++++++++++
  548.  
  549. From: lari@strauss.cs.unc.edu (Humayun Lari)
  550. Date: 12 Sep 92 20:31:09 GMT
  551. Organization: The University of North Carolina at Chapel Hill
  552.  
  553. In article <1992Sep11.005924.21955@dartvax.dartmouth.edu> Joe.Francis@dartmouth.edu (Joe Francis) writes:
  554. >In article <28629@vedge.UUCP>
  555. >brad@vedge.UUCP (Brad Fowlow) writes:
  556. >> Any thoughts on a PM-friendly way to get back the "normal"
  557. >> system palette when my last paletted window dies,
  558. >> just as happens when the app quits?
  559. >I'm hopeful that someone else will post a more elegant way, but one way
  560. >to do what you want is to detect when you are closing your only window,
  561. >EraseRect it's portRect, and set it's Palette to the system palette,
  562. >*then* close the window.  
  563.  
  564. How about this: close the window and then create a new window offscreen (i.e.
  565. with coordinates like 32000, 32000, 32010, 32010) Set its palette to the system
  566. palette, and the Palette Manager should do its job... or is it smart enough to
  567. check whether the window is onscreen? I'd test this, but I'm at school.
  568.  
  569. BTW, shouldn't the palette be a pure black-and-white palette, so as to be nice
  570. to the applications in the background? Or will this not work?
  571.  
  572. Humayun Lari
  573. (lari@cs.unc.edu)
  574.  
  575. ---------------------------
  576.  
  577. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  578. Subject: Palette Manager vs. Color Manager (was Re: NON-QUICKDRAW GAMES)
  579. Date: 10 Sep 92 18:21:47 GMT
  580. Organization: Kalamazoo College
  581.  
  582. (Sorry to the csmp folks who are tiring of this thread;  I think this
  583. article is relevant enough to be of interest to some programmers.)
  584.  
  585. deadman@garnet.berkeley.edu (Ben Haller) writes:
  586. >
  587. >In my experience using the palette manager means the screen does CLUT
  588. >flashes that are even more distracting than they would usually be (i.e.
  589. >it will often flash *several times*)
  590.  
  591. With all deference to your experience--I love the two games of yours
  592. that I've seen--I think your bad impressions are due to not using the PM
  593. for a long time, and to badly-behaved applications (such as yours :-).
  594.  
  595. I'm right now flipping back and forth between my app and GIFConverter
  596. (which uses the P.M.).  The clut changes exactly once, and each app
  597. redraws its window for the new color environment exactly once.  (Well,
  598. mine does it twice, but that's debugging code I haven't taken out yet.)
  599. With lots of windows, it takes a few seconds, but so do all
  600. mass-updates; what do you expect?
  601.  
  602. >the other applications
  603. >in the system are often permanantly fucked up and don't redraw correctly
  604. >from then on.
  605.  
  606. You may be thinking specifically of the Finder, which is courteous to
  607. the point of obsequiosity.  If its icon colors aren't immediately
  608. available, it doesn't even try to get them;  it just reverts to black
  609. and white.
  610.  
  611. Applications that use the P.M. properly will get the colors they
  612. request.  Those that don't, won't.
  613.  
  614. >Nobody else uses the Palette
  615. >Wrecker, and so all of the much-touted benefits simply aren't there (lack
  616. >of entry conflicts with other apps, etc.)
  617. >[later...]
  618. >what proportion of commercial apps do you suppose use
  619. >the Palette Manager?
  620.  
  621. I'd guess 90% of them, at least.  Those that don't cause conflicts.  For
  622. example, our staff artist uses Studio/8, which uses the Color Manager.
  623. It doesn't happen very often, but every once in a while, you'll notice
  624. that after quitting, the inverse table is out of sync--the Finder's
  625. icons are screwed up, some text prints in funny colors, and so on.  Only
  626. restarting fixes it.  And if you hate color flashes on context switches,
  627. try flipping in and out of Studio/8 a few times.
  628.  
  629. Same for those apps of mine that use the C.M.  It's totally unpredictable,
  630. and affects any system or machine.  I still have no idea what I did wrong.
  631.  
  632. Solarian II and Lunatic Fringe take over the whole screen.  Try putting
  633. them in a window, and doing context switches like a good little app.
  634. Not during game play, of course--just so I can start and keep track of a
  635. download between games, without having to quit.  Suddenly the C.M. isn't
  636. so useful, is it?  Unless your users like everything behind your window
  637. appear in truly bizarre colors.
  638.  
  639. Then, keep in mind what you have to do to prevent background apps from
  640. coming forward.  Sure, you just don't react to clicks on the desktop.
  641. But remember those FKEYs that call OpenDeskAcc()?  OK, you have to set
  642. that byte at ScrnDmpEnable--er, or do you clear it?  Now no one can
  643. cmd-shift-3 a snapshot of the game in action, and the boss wants a .GIF
  644. to put on the box ten minutes ago...
  645.  
  646. It's just not worth it.
  647.  
  648. >And it has a lot of drawbacks,
  649. >not the least being that's it's slow, it increases your code size,
  650.  
  651. It's as slow as it takes apps to redraw for a new color environment.
  652. Code size does not increase appreciably (though 'pltt' resources take up
  653. twice as much room as 'clut's, caveat ResEditer).
  654.  
  655. >it looks worse,
  656.  
  657. Oh come on!  Colors are colors.
  658.  
  659. >and it's (in my opinion) meither as aesthetically pleasing
  660. >nor as compatable as just saving & setting the CLUT (or part of the CLUT)
  661. >on resume events and restoring the parts you changed on suspend events.
  662.  
  663. And in my opinion it's a thousand times easier and more compatible.
  664.  
  665. >  Also, if you're using direct-to-screen as almost everyone does - in a
  666. >pixel-oriented paint program or in a video game - then you'll want the
  667. >whole CLUT to yourself
  668.  
  669. How many games do you know that really, really _need_ 256 colors--not
  670. 254 or 255 but 256?  If you're clut-flipping to simulate page-flipping,
  671. OK;  if you're writing for a 2-bit-deep screen, I can see that.  Most
  672. games get along fine with 254 colors.
  673.  
  674. Paint programs...well, Studio/8 uses the Color Manager and it _still_
  675. doesn't let you edit black and white.
  676.  
  677. >[in a later article...]
  678. >*But* - when another
  679. >application that doesn't use the Palette Manager *or* SetEntries get
  680. >brought to front, the environment is not restored.  The other applications
  681. >palette stays in place, and the app that wanted the system palette is
  682. >fucked (pardon the expression).
  683.  
  684. Wait a minute.  If your app wants the system palette, attach a clone of
  685. the system palette to its windows.  If you don't care what colors you
  686. have, what's the problem?
  687.  
  688. >But IMV-152 says "If the front window is an old-style window,
  689. >or if it has no assigned palette, the Palette Manager establishes the color
  690. >environment using a default palette.  For many simple application the
  691. >default palette will suffice."  To me this implies that you are supposed
  692. >to be more or less guaranteed the system palette unless you request
  693. >something else.  It doesn't seem to work this way.
  694.  
  695. You were supposed to rip that chapter out when you got IM VI.  :-)  That
  696. phrase is nowhere to be found now, having been replaced by "By creating
  697. a palette of colors for your application, you ensure that appropriate
  698. colors are available when its window becomes frontmost."
  699.  
  700. By "many simple applications" is meant "applications that only want
  701. black and white, and don't really care too much whether they get their
  702. other colors or not."
  703.  
  704. >BTW, anybody noticed the charming System 7 bug that when the Color Picker
  705. >comes up, after you dismiss it it leaves the CLUT fucked up?  Charming.
  706. >They haven't fixed that one yet, have they?
  707.  
  708. Nope;  but at least the Color Picker chapter no longer promises "it will
  709. not alter the clut."  That's another chapter you should have ripped out
  710. of IM V.  :-/
  711.  
  712. >There is nothing wrong with SetEntries - at least
  713. >nothing that the Wrecker fixes.  So why bother.
  714.  
  715. Except color arbitration with the large majority of apps that _do_ use
  716. the Palette Manager.  Except having to worry about ctSeeds and iTabSeeds;
  717. when to re-make the inverse table (do you have to after SetEntries?
  718. RestoreEntries? will Color2Index do it for you?);  sequence vs. index
  719. mode in SetEntries;  how to use your source-level debugger when you've
  720. set colors 0 and 255 to black...  Hey, three years ago I thought the
  721. Color Manager looked easier, and I wrote three games with it.  We
  722. still get about one tech call a week, "why does my text draw in aqua
  723. after I quit your game?"
  724.  
  725. The Palette Manager is the right choice for 99% of the apps out there--
  726. the 1% being those games which take over an entire screen, don't have a
  727. menubar, _and_ which truly need _every_ color in the table.  At present,
  728. I know of exactly one game which fulfills all three conditions.  (Storm,
  729. because it uses clut flipping.)
  730.  
  731.  
  732. If you followup, please edit the Followup-To line appropriately.  Thanks.
  733. - -- 
  734.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  735.  "Don't listen to Jamie, he averages several lies per message, especially when
  736.   they are directed towards me or are talking about me, this BBS, 'Holocaust
  737.   Deniers', etc.  I'm ignoring him now."   - Dan "Maynard" Gannon, 23 Aug 1992
  738.  
  739. +++++++++++++++++++++++++++
  740.  
  741. From: deadman@garnet.berkeley.edu (Ben Haller)
  742. Date: 11 Sep 1992 01:10:06 GMT
  743. Organization: Stick Software
  744.  
  745. [there is a lot in this posting that I'm replying to that had already
  746. been addressed in the prior discussion, so with all due respect, I'm
  747. deleting it...]
  748.  
  749. In article <1992Sep10.182147.25618@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  750. >deadman@garnet.berkeley.edu (Ben Haller) writes:
  751. >>Nobody else uses the Palette
  752. >>Wrecker, and so all of the much-touted benefits simply aren't there (lack
  753. >>of entry conflicts with other apps, etc.)
  754. >>[later...]
  755. >>what proportion of commercial apps do you suppose use
  756. >>the Palette Manager?
  757.  
  758. >I'd guess 90% of them, at least.  Those that don't cause conflicts.  For
  759. >example, our staff artist uses Studio/8, which uses the Color Manager.
  760. >It doesn't happen very often, but every once in a while, you'll notice
  761. >that after quitting, the inverse table is out of sync--the Finder's
  762. >icons are screwed up, some text prints in funny colors, and so on.  Only
  763. >restarting fixes it.  And if you hate color flashes on context switches,
  764. >try flipping in and out of Studio/8 a few times.
  765.   First: 90% is way high.  That's simply not reality, IMHO.  I could
  766. be wrong, but I have *serious* doubts about that estimate.  (of couse,
  767. both of us are just talking out of our ass, so whatever...)
  768.   Second: the inverse table being out of synch, etc., has nothing
  769. to do with the Color Manager.  I mean, the Palette Manager *uses*
  770. the Color Manager, no?  So how could it possibly be a bug in the
  771. Color Manager, and yet not be exhibited in PM apps?  No lo comprendo.
  772.   Third: Studio/8 would flash if it used the PM, too.  That's just
  773. the reality of using the whole CLUT.  Life sucks sometimes.
  774.  
  775. >Same for those apps of mine that use the C.M.  It's totally unpredictable,
  776. >and affects any system or machine.  I still have no idea what I did wrong.
  777.   Well, neither do I, but I can assure you my apps work fine.
  778.  
  779. >>  Also, if you're using direct-to-screen as almost everyone does - in a
  780. >>pixel-oriented paint program or in a video game - then you'll want the
  781. >>whole CLUT to yourself
  782. >How many games do you know that really, really _need_ 256 colors--not
  783. >254 or 255 but 256?  If you're clut-flipping to simulate page-flipping,
  784. >OK;  if you're writing for a 2-bit-deep screen, I can see that.  Most
  785. >games get along fine with 254 colors.
  786.   The thread has already discussed the problem with using the Palette
  787. Manager to get even 254 colors.
  788.   Please, pay attention.  I just deleted about forty lines of your post
  789. that showed even less attention to thread history than this.  Ok, sorry,
  790. flame off.  But really, I hate repetitive threads...
  791.  
  792. >Paint programs...well, Studio/8 uses the Color Manager and it _still_
  793. >doesn't let you edit black and white.
  794.   Studio/8 is pathetic.  Lay off the poor thing already.
  795.  
  796. >Wait a minute.  If your app wants the system palette, attach a clone of
  797. >the system palette to its windows.  If you don't care what colors you
  798. >have, what's the problem?
  799.   This has also been discussed.  It slows down CopyBits.  Read up, mate!
  800.  
  801. >You were supposed to rip that chapter out when you got IM VI.  :-)  That
  802. >phrase is nowhere to be found now, having been replaced by "By creating
  803. >a palette of colors for your application, you ensure that appropriate
  804. >colors are available when its window becomes frontmost."
  805. > ...
  806. >Nope;  but at least the Color Picker chapter no longer promises "it will
  807. >not alter the clut."  That's another chapter you should have ripped out
  808. >of IM V.  :-/
  809.   How come they keep changing the only parts I *like*??!?
  810.  
  811. >Except having to worry about ctSeeds and iTabSeeds;
  812. >when to re-make the inverse table (do you have to after SetEntries?
  813. >RestoreEntries? will Color2Index do it for you?);  sequence vs. index
  814. >mode in SetEntries;  how to use your source-level debugger when you've
  815. >set colors 0 and 255 to black...
  816.   SetEntries changes the ctSeed for you, which causes the ITable to
  817. be rebuilt for you.  If you really *want* to you can do the
  818. rebuilding yourself, though, I guess.  If you're a glutton for
  819. punishment...
  820.   I *like* sequence vs. index mode.
  821.   And I never use source-level debuggers.  Besides, I have a secondary
  822. monitor.  :->
  823.  
  824. >  Hey, three years ago I thought the
  825. >Color Manager looked easier, and I wrote three games with it.  We
  826. >still get about one tech call a week, "why does my text draw in aqua
  827. >after I quit your game?"
  828.   Well, that's your game.  SolII works fine, LF works fine, Satori and
  829. Mountains and all the other AD modules I've written that call SetEntries
  830. work fine...  What's the problem with *your* code?
  831.   I've never seen anyone defend a crappy piece of code like the
  832. Palette Manager by saying that code they wrote a few years ago
  833. that didn't use it was buggy...
  834.  
  835. >The Palette Manager is the right choice for 99% of the apps out there--
  836. >the 1% being those games which take over an entire screen, don't have a
  837. >menubar, _and_ which truly need _every_ color in the table.  At present,
  838. >I know of exactly one game which fulfills all three conditions.  (Storm,
  839. >because it uses clut flipping.)
  840.   Oh, nonsense.  Get a life.  How about: anything that doesn't use
  841. a window.  Anything that needs more precise control, or greater speed,
  842. than the Palette Manager gives you?  Anything written by someone who
  843. doesn't feel like wasting their time using a high-level, buggy,
  844. annoying manager to do something when there's a perfectly well-documented
  845. and supported way of *avoiding* the damn thing?  Really, see if you
  846. can get your DTS fever a little more stoked up!
  847.  
  848. >If you followup, please edit the Followup-To line appropriately.  Thanks.
  849.   Well, I took out alt.religion.computers or some such group that I've
  850. never even *heard of* before.  Is that what you wanted me to do?
  851.   You also mistyped "programmer" in "comp.sys.mac.programmer" - you
  852. added an extra "ers" on the end.  I have no idea why your posting
  853. software didn't bark - mine sure did, four times!
  854.  
  855.   Sorry if this message is a little flaming, but really, it's annoying that
  856. you seem to have completely ignored half of the point of all the previous
  857. messages in this thread.
  858.  
  859. - -Ben Haller (deadman@garnet.berkeley.edu)
  860.  
  861. +++++++++++++++++++++++++++
  862.  
  863. From: smargari@nmsu.edu (Susan Margarit)
  864. Date: 12 Sep 92 04:18:14 GMT
  865. Organization: NMSU Computer Science
  866.  
  867. BH> Sorry if this message is a little flaming, but really, it's
  868. annoying....
  869.  
  870. Say, didn't I read about you recently? Something about spitting on
  871. State Department or Apple DTS faxes and playing games in a war zone?
  872. Or was that another games genius with an attitude...  ;)
  873.  
  874.   Jim Margarit
  875.  
  876. +++++++++++++++++++++++++++
  877.  
  878. From: deadman@garnet.berkeley.edu (Ben Haller)
  879. Date: 13 Sep 1992 00:46:35 GMT
  880. Organization: Stick Software
  881.  
  882. In article <SMARGARI.92Sep11211814@emmy.nmsu.edu>
  883.   smargari@nmsu.edu (Susan Margarit) writes:
  884. >Say, didn't I read about you recently? Something about spitting on
  885. >State Department or Apple DTS faxes and playing games in a war zone?
  886. >Or was that another games genius with an attitude...  ;)
  887.  
  888.   Hmm.  I dunno, where did you read it?  I certainly hate the
  889. State Department, but I haven't been near enough to it to spit
  890. on it recently.  I never fax to DTS, or indeed deal with DTS in
  891. any way.  Playing games in a war zone?  Well, inasmuch as the US
  892. (and Berkeley in particular) is a war zone, this makes perfect sense.
  893.   Magazines never *tell* you that they've written an article on
  894. or mentioning you, so I probably am not aware of most of the things
  895. that get said about me in the press.  I wish they had better manners -
  896. they could at least send me a copy if they mention me...just so
  897. I can at least sue them for libel :->
  898.   BTW, I don't know why you posted this, so I posted back.  Take it
  899. to e-mail unless you have a reason not to...
  900.  
  901. - -Ben Haller (deadman@garnet.berkeley.edu)
  902.  
  903. ---------------------------
  904.  
  905. From: mhall@occs.cs.oberlin.edu (Matthew Hall)
  906. Subject: The Pallette manager
  907. Date: 8 Sep 92 20:58:08 GMT
  908. Organization: Oberlin College Computer Science
  909.  
  910.  
  911. I have a question that's not directly related to the games thread, but
  912. its close.
  913.  
  914. I am drawing a 256 color plot in an offscreen pixmap.  I set the
  915. offscreen pmtable to whatever clut I wish to choose.  Then, from that
  916. I creat a palette optimized for the current color level (or none for
  917. direct devices).  So, if I'm in 16 colors, I would take one of every
  918. 16 colors in the 256 color clut that I loaded in (with black and white
  919. appropriately placed) and place them in the palette. Then I set the
  920. app's default palette to this new palette.
  921.  This way, I can
  922. draw directly into the offscreen map since the positions of the colors
  923. in the clut don't change, and I don't have to use
  924. pmtolerant+pmexplicit, or setentries, and I can draw in an ideal color
  925. environment and let PM take care of tolerance and updates.  Now - two problems
  926.  
  927. It runs very oddly in the system 7 finder.  Sometimes the menus are
  928. dimmed by gray color, sometimes by gray pattern.  When I switch to the
  929. finder, sometimes dimmed menus are displayed as an attrocious shade of
  930. magenta.  I guess in the previous thread it says that the finder is
  931. "courteous to the point of obsequity", but magenta menus?
  932.  
  933. Also, I want to create a black background offscreen, I switch to the 
  934. offscreen port.  I call a fillrect (backpat=black,backcolor=0,0,0);
  935. and then copybits to the screen.(with the window as the current port)
  936. At this point, the cluts first and last entries are white and black
  937. respectively.  If I am in an indexed environment, everything is
  938. hunky-dory. If I am in a direct environment, the background stays
  939. white, and if I switch between the two, I usually get a cyan  (one of
  940. the earlier entries in my clut). 
  941.  Now when I draw direct (plug index values in the data) into the
  942. pixmap, and copybits to the screen 
  943. everything is fine. $FF turns to black, etc.  So the problem seems to
  944. be that fillrect is placing the (teh) wrong index into the pixmap.  Is
  945. this because my offscreen port is using the current gdevice, and
  946. thinks black is somewhere else in my clut than it actually is? If so,
  947. do I have to create a new gdevice for the pixmap?  
  948. Actually, is my method compatible? Is it stupid?  and why the strange
  949. problems.
  950.  
  951. Any help appreciated,
  952. - -matt hall
  953. - --
  954.  
  955.  
  956. - -------------------------------------------------------------------------------
  957. Matt Hall.    mhall@occs.cs.edu  OR  SMH9666@OBERLIN.BITNET
  958.               (216)-775-5805 (That's a Cleveland Area code. Lucky Me)
  959.  
  960. "If a man comes up to you and says:
  961.     'A dog just carried away your ear.'
  962. Do you run after the dog, or search first for your ear?" - Moon over Morocco
  963.   
  964.  
  965. +++++++++++++++++++++++++++
  966.  
  967. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  968. Date: 11 Sep 92 18:18:06 +1200
  969. Organization: University of Waikato, Hamilton, New Zealand
  970.  
  971. In article <MHALL.92Sep8155808@occs.cs.oberlin.edu>, mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  972. >
  973. > I am drawing a 256 color plot in an offscreen pixmap.  I set the
  974. > offscreen pmtable to whatever clut I wish to choose.  Then, from that
  975. > I creat a palette optimized for the current color level (or none for
  976. > direct devices).  So, if I'm in 16 colors, I would take one of every
  977. > 16 colors in the 256 color clut that I loaded in (with black and white
  978. > appropriately placed) and place them in the palette. Then I set the
  979. > app's default palette to this new palette.
  980.  
  981. An easier way might be to use the pmInhibit flags. That way you can specify
  982. for each palette entry which screen depths to use it at, and you don't have
  983. to check the screen depth before setting up your palette.
  984.  
  985. >  This way, I can
  986. > draw directly into the offscreen map since the positions of the colors
  987. > in the clut don't change, and I don't have to use
  988. > pmtolerant+pmexplicit, or setentries, and I can draw in an ideal color
  989. > environment and let PM take care of tolerance and updates.
  990.  
  991. Hang on--you don't need a palette for an offscreen port. The main point of
  992. palettes is for use with on-screen windows. The only point with attaching
  993. a palette to an offscreen port would be so you can use PmForeColor and
  994. PmBackColor to quickly specify colours from the palette. Tolerant and
  995. animated entries don't mean anything in an offscreen palette.
  996.  
  997. [problems with on-screen display omitted]
  998.  
  999. >  Now when I draw direct (plug index values in the data) into the
  1000. > pixmap, and copybits to the screen
  1001. > everything is fine. $FF turns to black, etc.  So the problem seems to
  1002. > be that fillrect is placing the (teh) wrong index into the pixmap.  Is
  1003. > this because my offscreen port is using the current gdevice, and
  1004. > thinks black is somewhere else in my clut than it actually is? If so,
  1005. > do I have to create a new gdevice for the pixmap?
  1006. > Actually, is my method compatible? Is it stupid?  and why the strange
  1007. > problems.
  1008.  
  1009. What exactly *is* your method? If you're directly poking colour table
  1010. entries, are you remembering to call CTabChanged so QuickDraw knows what
  1011. you've been up to? If you want a custom colour table for your pixmap, then
  1012. *YES*, you *DO* have to create a custom GDevice. This is because the mapping
  1013. from the colours you ask for to actual pixel values is done using an inverse
  1014. colour table, and you find those in the GDevice structure, not in the PixMap.
  1015.  
  1016. Are you using the GWorld routines? If not, I highly recommend them. Here's how
  1017. you create a GWorld:
  1018.  
  1019.     Err := NewGWorld
  1020.       (
  1021.         MyGWorld, (* ptr to returned GWorld *)
  1022.         PixelDepth, (* number of bits per pixel *)
  1023.         BoundsRect, (* bounds of GWorld's PortRect *)
  1024.         CTable, (* custom colour table or NIL for default *)
  1025.         NIL, (* don't want to use an existing GDevice *)
  1026.         Flags (* specifying useTempMem puts pixmap into temporary memory *)
  1027.       )
  1028.  
  1029. You can read the rest in IM6. The GWorld routines really are easy to use.
  1030. Compatible, too.
  1031.  
  1032. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1033. Computer Services Dept                     fax: +64-7-838-4066
  1034. University of Waikato            electric mail: ldo@waikato.ac.nz
  1035. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1036.                        Signature tow-away zone. You have been wa
  1037.  
  1038. +++++++++++++++++++++++++++
  1039.  
  1040. From: mhall@occs.cs.oberlin.edu (Matthew Hall)
  1041. Date: 11 Sep 92 21:28:09 GMT
  1042. Organization: Oberlin College Computer Science
  1043.  
  1044. In article <1992Sep11.181806.10762@waikato.ac.nz> ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  1045.  
  1046. >
  1047. >   >  This way, I can
  1048. >   > draw directly into the offscreen map since the positions of the colors
  1049. >   > in the clut don't change, and I don't have to use
  1050. >   > pmtolerant+pmexplicit, or setentries, and I can draw in an ideal color
  1051. >   > environment and let PM take care of tolerance and updates.
  1052. >
  1053. >   Hang on--you don't need a palette for an offscreen port. The main point of
  1054. >   palettes is for use with on-screen windows. The only point with attaching
  1055. >   a palette to an offscreen port would be so you can use PmForeColor and
  1056. >   PmBackColor to quickly specify colours from the palette. Tolerant and
  1057. >   animated entries don't mean anything in an offscreen palette.
  1058. >
  1059. I should have been clearer.  I load a 256 color pallette from a
  1060. resource file with GetCTable.  Then I set
  1061. Offscreen^.portpixmap^^.pmtable equal to that clut.  Then, I create a
  1062. palette for the current screen depth, and fill it with values from the
  1063. clut.  The palette is only for the window that the plot will
  1064. eventually be displayed in.  I draw in the offscreen pixmap by
  1065. directly setting the bytes.  If I loaded a gray scale, then the level
  1066. of gray is from 0-255.  I just place that byte in the pixmap data.
  1067. When I am done, I call copybits from the port to the screen.
  1068.  
  1069.  
  1070.  
  1071. >   What exactly *is* your method? If you're directly poking colour table
  1072. >   entries, are you remembering to call CTabChanged so QuickDraw knows what
  1073. >   you've been up to? 
  1074.  
  1075. No I haven't.  I didn't even know I was supposed to.  Thanks.
  1076.  
  1077. >If you want a custom colour table for your pixmap, then
  1078. >  *YES*, you *DO* have to create a custom GDevice. This is because the mapping
  1079. >  from the colours you ask for to actual pixel values is done using an inverse
  1080. > colour table, and you find those in the GDevice structure, not in the PixMap.
  1081. >
  1082. >Are you using the GWorld routines? If not, I highly recommend them. Here's how
  1083. >   you create a GWorld:
  1084.  
  1085. The problem is that I want this to be compatible with as many
  1086. computers as it can.  GWorlds are only in sys 7 and 32 bit quickdraw
  1087. equipped Macs.  Inhibited colors are only in systems 6.0.5 and later.
  1088. I may be able to assume that anyone running color should be running
  1089. 6.0.5, so maybe I will use inhibited colors, and just create one
  1090. palette, but I don't want to assume system 7, or 32-bit QD.
  1091. Of course, my compatibility concerns are worthless if my method
  1092. crashes most computers or graphics cards.  It works on an LC tho'
  1093.  
  1094. I guess I will have to create a gDevice for the offscreen port then.
  1095. The only quickdraw call I make, besides copybits, is fillrect though.
  1096. Otherwise I just poke in numbers.  it seems kind of a waste of memory
  1097. to create a GDevice just for FillRect when otherwise things seem to be
  1098. working well.  I can't see any problems with accelerator cards since I
  1099. don't modify screen data directly.  
  1100.  
  1101. Thanks for the help
  1102. - -matt hall
  1103.  
  1104. - --
  1105.  
  1106.  
  1107. - -------------------------------------------------------------------------------
  1108. Matt Hall.    mhall@occs.cs.edu  OR  SMH9666@OBERLIN.BITNET
  1109.               (216)-775-5805 (That's a Cleveland Area code. Lucky Me)
  1110.  
  1111. "If a man comes up to you and says:
  1112.     'A dog just carried away your ear.'
  1113. Do you run after the dog, or search first for your ear?" - Moon over Morocco
  1114.   
  1115.  
  1116. ---------------------------
  1117.  
  1118. End of C.S.M.P. Digest
  1119. **********************
  1120.